class_name AudioView
extends BaseView

#region 属性
@export var bgm_slider:HSlider
@export var sfx_slider:HSlider
var connect_obj_dict:Dictionary[Signal,ConnectObj] = {}
#endregion
#region 字段
#endregion
#region 信号
#endregion

#region 基类方法
func init_view():
	super.init_view()
func on_enter(args:Dictionary = {}):
	super.on_enter(args)
	connect_obj_dict[bgm_slider.drag_ended] = ConnectObj.new(bgm_slider.drag_ended,[_on_set_bgm_vol])
	connect_obj_dict[sfx_slider.drag_ended] = ConnectObj.new(sfx_slider.drag_ended,[_on_set_sfx_vol])
	update_vol()
func on_pause(args:Dictionary = {}):
	super.on_pause(args)
func on_resume(args:Dictionary = {}):
	super.on_resume(args)
func on_exit(args:Dictionary = {}):
	for connect_obj:ConnectObj in connect_obj_dict.values():
		if connect_obj:
			connect_obj.disconnect_all()
	super.on_exit(args)
func get_view_state() -> GameEnum.ViewState:
	return super.get_view_state()
#endregion
#region 公共方法
func update_vol():
	bgm_slider.value = GameAudioSystem.bgm_vol_db
	sfx_slider.value = GameAudioSystem.sfx_vol_db
#endregion
#region 私有方法
func _on_set_bgm_vol(value_changed:bool):
	if not value_changed:
		return
	GameAudioSystem.set_bgm_vol(bgm_slider.value)
func _on_set_sfx_vol(value_changed:bool):
	if not value_changed:
		return
	GameAudioSystem.set_sfx_vol(sfx_slider.value)
#endregion
#region 生命周期函数
#endregion
